package com.tyl.mapper;

import com.tyl.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper {
    //通过用户名查询用户
    @Select("select id as id, name as user ,pwd as password  from mybatis.user")
    List<User> getUserList();

    //通过id获取用户
    @Select("select id as id, name as user ,pwd as password  from mybatis.user where id=#{uid}")
    User getIdBy(@Param("uid") int id);

    //新增用户
    @Insert("insert into mybatis.user(id, name, pwd) value (#{id},#{user},#{password})")
    int addByUser(User user);

    //按Id删除用户
    @Delete("delete from mybatis.user where id=#{uid}")
    int deleteByUser(@Param("uid") int id);

}
